class Vector:
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def __str__(self):
        return 'Vector (%d, %d)' % (self.a, self.b)

    def __add__(self, other):
        return Vector(self.a + other.a, self.b + other.b)

    def eat(self):
        pass

v1 = Vector(2, 10)
v2 = Vector(5, -2)
print(v1 + v2)

# ======================================================================

#类属性 类方法

class Tool(object):
    count = 0  # 类属性

    def __init__(self, name):
        Tool.count += 1

    def demo(self):
        print("通过类方法调用 实例方法")

    # 类方法
    @classmethod
    def show_tool(cls):
        print("工具对象数量%d " % cls.count)
        cls.demo(Tool)

tool1 = Tool("斧子")

Tool.show_tool()  # 调用类方法

# ======================================================================

# 静态方法
class Dot(object):

    @staticmethod
    def run():
        print("123")

Dot.run()

